﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Microsoft.Xna.Framework;

namespace Fusion.Interface
{
    public class Toolbar : Prop
    {
        #region Attributes

        public List<Button> contents = new List<Button>();
        public Vector2 iconSize = Vector2.One * 48;
        public bool hovered;

        #endregion

        #region Constructors

        public Toolbar( float size )
        {
            iconSize = Vector2.One * size;
        }

        #endregion

        #region Methods

        /// <summary> Adds a button to the end of the toolbar </summary>
        /// <param name="cel">Graphic cel to use</param>
        /// <param name="clicked">Click delegate</param>
        /// <param name="released">Release delegate</param>
        public Button AddButton( Rectangle rect, VoidDelegate clicked, VoidDelegate released )
        {
            Button btn = new Button( new Vector2( contents.Count * iconSize.X, 0 ), iconSize, "Buttons", rect, rect, clicked, released );
            btn.container = this;
            contents.Add( btn );
            return btn;
        }

        public void Control( Cursor cursor )
        {
            hovered = false;
            foreach( Button button in contents )
            {
                //button.Control( cursor );
                if( button.hovered == true )
                    hovered = true;
            }
        }

        public override void Draw()
        {
            foreach( Button button in contents )
                button.Draw();

            base.Draw();
        }

        #endregion
    }
}
